﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Business.Entity;
using System.Data.SqlClient;
using System.Data;

namespace Business.Dal
{
    class ResimProvider:Provider<Resimler>
    {

        public override bool Insert(Resimler tObject)
        {
            bool returnValue = false;
            string silBunu = "";
            SqlCommand cmd = new SqlCommand("ResimEkle");
            cmd.CommandType= CommandType.StoredProcedure;
            cmd.Connection= Tools.Connection();
            Tools.Open();
            cmd.Parameters.Add("@IlanID", SqlDbType.Int).Value = tObject.ResimID;
            cmd.Parameters.Add("@ServerFileName", SqlDbType.VarChar).Value = tObject.ServerFileName;
            tObject.ResimID = Convert.ToInt32(cmd.ExecuteScalar());
            returnValue = true;
            return returnValue;


        }

        public override bool Update(Resimler tObject)
        {
            bool returnValue = false;
            SqlCommand cmd = new SqlCommand("ResimGuncellexxxxx");
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = Tools.Connection();
            Tools.Open();
            cmd.Parameters.Add("@ResimID", SqlDbType.Int).Value = tObject.ResimID;
            cmd.Parameters.Add("@IlanID", SqlDbType.Int).Value = tObject.IlanID;
            cmd.Parameters.Add("@ServerFileName", SqlDbType.Int).Value = tObject.ServerFileName;
            returnValue = Convert.ToBoolean(cmd.ExecuteScalar());
            return returnValue;
        }

        public override bool Delete(int RecordID)
        {
            bool returnValue = false;
            SqlCommand cmd = new SqlCommand("ResimID");
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = Tools.Connection();
            Tools.Open();

            cmd.Parameters.Add("@ResimID", SqlDbType.Int).Value = RecordID;

            returnValue = Convert.ToBoolean(cmd.ExecuteNonQuery());

            return returnValue;
        }
        public Resimler ResimGetir(int IlanID)
        {
            SqlCommand cmd = new SqlCommand("ResimGetirIlanID");
        cmd.CommandType= CommandType.StoredProcedure;
            cmd.Connection= Tools.Connection();
            Tools.Open();
            cmd.Parameters.Add("@IlanID", SqlDbType.Int).Value= IlanID;
            SqlDataReader dr;
            dr= cmd.ExecuteReader();
            dr.Read();
        }
    }
}
